/*
 * ============================================================================
 *
 *  [THC RPG] Total HardCore RPG
 *
 *  File:          <upgradename>.inc
 *  Type:          Upgrade
 *  Description:   <description>
 *
 *  Copyright (C) 2009-2010  ArsiRC
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ============================================================================
 */

/**
 * This module's identifier.
 */
new Module:g_module<upgradename>;

new g_<upgradename>UpgradeConfigCache[UpgradeConfigs];

/**
 * Register this module.
 */
<upgradename>_Register()
{
    // Define all the module's data as layed out by enum ModuleData in project.inc.
    new moduledata[ModuleData];
    
    moduledata[ModuleData_Disabled] = false;
    moduledata[ModuleData_Hidden] = false;
    strcopy(moduledata[ModuleData_FullName], MM_DATA_FULLNAME, "<upgradename>");
    strcopy(moduledata[ModuleData_ShortName], MM_DATA_SHORTNAME, "<upgradename>");
    strcopy(moduledata[ModuleData_Description], MM_DATA_DESCRIPTION, "<description>");
    
    new Module:dependencies[MM_DATA_DEPENDENCIES];
    dependencies[0] = g_moduleCore;
    dependencies[1] = INVALID_MODULE;
    moduledata[ModuleData_Dependencies] = dependencies;

    new Module:interlocks[MM_DATA_INTERLOCKS];
    interlocks[0] = INVALID_MODULE;
    moduledata[ModuleData_Interlocks] = interlocks;
    
    moduledata[ModuleData_TeamLock] = 0;
    moduledata[ModuleData_MaxLevel] = 5;
    moduledata[ModuleData_Cost] = 5;
    moduledata[ModuleData_iCost] = 10;

    // Send this array of data to the module manager.
    g_module<upgradename> = ModuleMgr_Register(moduledata);
    
    // Now register the events we're going to use.
    #if defined EVENT_MANAGER
        EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnEventsRegister", "<upgradename>_OnEventsRegister");
    #endif
        
    // Register config file(s) that this module will use.
    #if defined CONFIG_MANAGER
        ConfigMgr_Register(g_module<upgradename>, "<upgradename>_OnConfigReload", "configs/thc_rpg/<upgradename>.txt");
    #endif
}

/**
 * Register all events here.
 */
public <upgradename>_OnEventsRegister()
{
    // Register all the events needed for this module.
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnAllPluginsLoaded",      "<upgradename>_OnAllPluginsLoaded");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnPluginEnd",             "<upgradename>_OnPluginEnd");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnAllModulesLoaded",      "<upgradename>_OnAllModulesLoaded");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnModuleEnable",          "<upgradename>_OnModuleEnable");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnMyModuleEnable",        "<upgradename>_OnMyModuleEnable");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnModuleDisable",         "<upgradename>_OnModuleDisable");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnMyModuleDisable",       "<upgradename>_OnMyModuleDisable");
    EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnMapStart",              "<upgradename>_OnMapStart");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnMapEnd",                "<upgradename>_OnMapEnd");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnAutoConfigsBuffered",   "<upgradename>_OnAutoConfigsBuffered");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnConfigsExecuted",       "<upgradename>_OnConfigsExecuted");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnClientPutInServer",     "<upgradename>_OnClientPutInServer");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnClientDisconnect",      "<upgradename>_OnClientDisconnect");
    #if defined PROJECT_GAME_CSS
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_RoundStart",              "<upgradename>_RoundStart");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_RoundFreezeEnd",          "<upgradename>_RoundFreezeEnd");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_RoundEnd",                "<upgradename>_RoundEnd");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_PlayerTeam",              "<upgradename>_PlayerTeam");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_PlayerSpawn",             "<upgradename>_PlayerSpawn");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_PlayerHurt",              "<upgradename>_PlayerHurt");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_PlayerDeath",             "<upgradename>_PlayerDeath");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_PlayerJump",              "<upgradename>_PlayerJump");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_WeaponFire",              "<upgradename>_WeaponFire");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_BombPlanted",             "<upgradename>_BombPlanted");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_BombDefused",             "<upgradename>_BombDefused");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_BombExploded",            "<upgradename>_BombExploded");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_HostageRescued",          "<upgradename>_HostageRescued");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_HostageRescuedAll",       "<upgradename>_HostageRescuedAll");
        //EventMgr_RegisterEvent(g_module<upgradename>, "Event_SmokegrenadeDetonate",    "<upgradename>_SmokegrenadeDetonate");
      #endif
    
    // Custom events
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnUpgradePurchase,        "<upgradename>_OnUpgradePurchase");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnUpgradeSell,            "<upgradename>_OnUpgradeSell");
    //EventMgr_RegisterEvent(g_module<upgradename>, "Event_OnGameFrame",             "<upgradename>_OnGameFrame");
}

/**
 * All modules and events have been registered by this point.  Event priority can be changed here.
 */
public <upgradename>_OnEventsReady()
{
}

#if defined CONFIG_MANAGER
/**
 * Called when a registered config file (by this module) is manually reloaded.
 */
public <upgradename>_OnConfigReload(configindex)
{
    #if defined LOG_MANAGER
        LogMgr_Print(g_module<upgradename>, LogType_Normal, "<upgradename>ConfigReload", "Reloaded <upgradename> module's config (index %d)", configindex);
    #endif

    ConfigMgr_CacheKv(g_module<upgradename>, CM_CONFIGINDEX_FIRST, "<upgradename>Module_ConfigCache");
}

/**
  * Read config values
  */
public KvCache:<upgradename>Module_ConfigCache(Handle:kv, sectionindex, const String:sectionname[])
{
    // Read Upgrade config
    if(StrEqual(sectionname, "<upgradename>"))
    {
        g_<upgradename>UpgradeConfigCache[UpgradeConfig_Disable] = KvGetNum(kv, "disable");
        g_<upgradename>UpgradeConfigCache[UpgradeConfig_TeamLock] = KvGetNum(kv, "teamlock");
        g_<upgradename>UpgradeConfigCache[UpgradeConfig_MaxLevel] = KvGetNum(kv, "maxlevel");
        g_<upgradename>UpgradeConfigCache[UpgradeConfig_Cost] = KvGetNum(kv, "cost");
        g_<upgradename>UpgradeConfigCache[UpgradeConfig_iCost] = KvGetNum(kv, "icost");

        if(g_<upgradename>UpgradeConfigCache[UpgradeConfig_Disable]==1)
          ModuleMgr_Disable(g_module<upgradename>);

        ModuleMgr_WriteCell(g_module<upgradename>, ModuleData_MaxLevel, g_<upgradename>UpgradeConfigCache[UpgradeConfig_MaxLevel]);
        ModuleMgr_WriteCell(g_module<upgradename>, ModuleData_Cost, g_<upgradename>UpgradeConfigCache[UpgradeConfig_Cost]);
        ModuleMgr_WriteCell(g_module<upgradename>, ModuleData_iCost, g_<upgradename>UpgradeConfigCache[UpgradeConfig_iCost]);
    }
}
#endif


/**
 * All plugins have loaded.
 */
public <upgradename>_OnAllPluginsLoaded()
{
}

/**
 * Plugin is ending.
 */
public <upgradename>_OnPluginEnd()
{
}

/**
 * All modules have been registered.
 */
public <upgradename>_OnAllModulesLoaded()
{
}

/**
 * A module has been enabled.
 *
 * @return      Return Plugin_Handled to stop enable, and Plugin_Continue to allow it.
 */
public Action:<FuncPrefix>_OnModuleEnable(Module:module)
{
}

/**
 * The module that hooked this event callback has been enabled.
 *
 * @param refusalmsg    The string that is printed if Plugin_Handled is returned and it is non-empty.
 * @param maxlen        The max length of the string.
 *
 * @return      Return Plugin_Handled to stop enable, and Plugin_Continue to allow it.
 */
public Action:<FuncPrefix>_OnMyModuleEnable(String:refusalmsg[], maxlen)
{
}

/**
 * A module has been disabled.
 */
public <FuncPrefix>_OnModuleDisable(Module:module)
{
}

/**
 * A module has been disabled.
 *
 * @return      Return Plugin_Handled to stop disable, and Plugin_Continue to allow it.
 */
public Action:<FuncPrefix>_OnModuleDisable(Module:module)
{
}

/**
 * The module that hooked this event callback has been disabled.
 *
 * @param refusalmsg    The string that is printed if Plugin_Handled is returned and it is non-empty.
 * @param maxlen        The max length of the string.
 *
 * @return      Return Plugin_Handled to stop disable, and Plugin_Continue to allow it.
 */
public Action:<FuncPrefix>_OnMyModuleDisable(String:refusalmsg[], maxlen)
{
}

/**
 * The map has started.
 */
public <upgradename>_OnMapStart()
{
    #if defined CONFIG_MANAGER
        ConfigMgr_CacheKv(g_module<upgradename>, CM_CONFIGINDEX_FIRST, "<upgradename>Module_ConfigCache");
    #endif
}

/**
 * The map has ended.
 */
public <upgradename>_OnMapEnd()
{
}

/**
 * This is called before OnConfigsExecuted but any time after OnMapStart.
 * Per-map settings should be set here. 
 */
public <upgradename>_OnAutoConfigsBuffered()
{
}

/**
 * All convars are set, cvar-dependent code should use this.
 */
public <upgradename>_OnConfigsExecuted()
{
}

/**
 * Client has joined the server.
 * 
 * @param client    The client index.
 */
public <upgradename>_OnClientPutInServer(client)
{
}

/**
 * Client is disconnecting from the server.
 * 
 * @param client    The client index.
 */
public <upgradename>_OnClientDisconnect(client)
{
}

/**
 * Round has started.
 */
public <upgradename>_RoundStart()
{
}

/**
 * Pre-round has freezetime has finished.
 */
public <upgradename>_RoundFreezeEnd()
{
}

/**
 * Round has ended.
 */
public <upgradename>_RoundEnd()
{
}

/**
 * Client has joined a team.
 * 
 * @param client        The client index.
 * @param team          The client's new team.
 * @param oldteam       The team the client is switching from.
 * @param disconnect    True if the client is disconnecting, false if switching to a team.
 */
public <upgradename>_PlayerTeam(client, team, oldteam, bool:disconnect)
{
}

/**
 * Client has spawned.
 * 
 * @param client    The client index.
 * 
 */
public <upgradename>_PlayerSpawn(client)
{
}

/**
 * Client has been damaged.
 * 
 * @param victim        The index of the hurt client.
 * @param attacker      The index of the attacking client.
 * @param health        How much <upgradename> the client has after the damage.
 * @param armor         How much armor the client has after the damage.
 * @param weapon        The weapon classname used to hurt the victim. (No weapon_ prefix)
 * @param dmg_health    The amount of <upgradename> the victim lost.
 * @param dmg_armor     The amount of armor the victim lost.
 * @param hitgroup      The hitgroup index of the victim that was damaged.
 */
public <upgradename>_PlayerHurt(victim, attacker, health, armor, const String:weapon[], dmg_health, dmg_armor, hitgroup)
{
}

/**
 * Client has been killed.
 * 
 * @param victim    The index of the killed client.
 * @param attacker  The killer of the victim.
 * @param weapon    The weapon classname used to kill the victim. (No weapon_ prefix)
 * @param headshot  True if the death was by headshot, false if not.
 */
public <upgradename>_PlayerDeath(victim, attacker, const String:weapon[], bool:headshot)
{
}

/**
 * Client has jumped.
 * 
 * @param client        The client index.
 */
public <upgradename>_PlayerJump(client)
{
}

/**
 * Client has fired a weapon.
 * 
 * @param client        The client index.
 * @param weapon        The weapon classname fired. (No weapon_ prefix)
 */
public <upgradename>_WeaponFire(client, const String:weapon[])
{
}

/**
 * Client has planted the bomb
 *
 * @param planter       The client who has planted the bomb
 */
public <upgradename>_BombPlanted(planter)
{
}

/**
 * Client has defused the bomb
 *
 * @param defuser       The client who has defused the bomb
 */
public <upgradename>_BombDefused(defuser)
{
}

/**
 * The bomb has exploded
 *
 * @param planter       The client who has planted the bomb
 */
public <upgradename>_BombExploded(planter)
{
}

/**
 * Client has rescued a hostage
 *
 * @param rescuer       The client who has rescued a hostage
 */
public <upgradename>_HostageRescued(rescuer)
{
}

/**
 * All hostages got rescued
 */
public <upgradename>_HostageRescuedAll()
{
}

/**
 * Smokegrenade has detonated
 *
 * @param thrower       The client who has thrown the smokegrenade
 */
public <upgradename>_SmokegrenadeDetonate(thrower)
{
}

/**
 * Client has purchased an Upgrade
 */
public <upgradename>_OnUpgradePurchase(client, level)
{
}

/**
 * Client has sold an Upgrade
 */
public <upgradename>_OnUpgradeSell(client, level)
{
}

/**
 * Called before every server frame.
 * Note that you should avoid doing expensive computations here,
 * and you should declare large local arrays using 'decl' instead of 'new' 
 */
public <upgradename>_OnGameFrame()
{
}
